import { Link } from '@brillout/docpress'
import { ConfigSpec } from '../../components'

<ConfigSpec
  env="server"
  isTypeOneLiner
>
`'HTML_BEGIN' | 'HTML_END' | 'STREAM' | null {:ts}`
</ConfigSpec>

Vike injects scripts at three possible positions:
- At the end of the HTML.
- At the beginning of the HTML.
- At the beginning of the <Link href="/streaming">HTML stream</Link>.

Depending on heuristics, Vike makes a sensible choice about where to inject scripts.

You can use the `injectScriptsAt` setting to override Vike's heuristics and control where Vike injects scripts.

> Alternatively, for a more fine-grained control of where and what assets Vike injects, use <Link href="/injectFilter">`injectFilter()`</Link>.

```ts
// +config.ts

import type { Config } from 'vike/types'

export default {
  // Inject scripts at the beginning of the HTML
  injectScriptsAt: 'HTML_BEGIN',
  // Inject scripts at the end of the HTML
  injectScriptsAt: 'HTML_END',
  // Inject scripts at the beginning of the HTML stream
  injectScriptsAt: 'STREAM',
  // Let Vike decide
  injectScriptsAt: null
} satisfies Config
```

> Setting `injectAssetsAt` to `null` can be useful in the context of <Link href="/config#inheritance">config inheritance</Link>.

## See also

- <Link href="/injectFilter" />
- <Link href="/settings" />
